<template>
  <div class="permission-placeholder">
    <div class="placeholder-content">
      <el-result
        icon="info"
        title="权限管理模块"
        sub-title="此模块包含用户管理、授权管理等功能"
      >
        <template #extra>
          <div class="menu-navigation">
            <p class="navigation-tip">请从左侧菜单选择具体功能：</p>
            <div class="menu-links">
              <router-link
                v-for="item in menuItems"
                :key="item.path"
                :to="item.path"
                class="menu-link"
              >
                <el-button type="primary" :icon="item.icon">
                  {{ item.title }}
                </el-button>
              </router-link>
            </div>
          </div>
        </template>
      </el-result>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useAuthStore } from '@/stores/auth'
import { User, Key } from '@element-plus/icons-vue'

const authStore = useAuthStore()

// 菜单项
const menuItems = computed(() => {
  const items = []

  if (authStore.canManageUsers) {
    items.push({
      path: '/users',
      title: '用户管理',
      icon: User
    })
    items.push({
      path: '/permission/product-permissions',
      title: '产品权限管理',
      icon: Key
    })
  }

  return items
})
</script>

<style scoped>
.permission-placeholder {
  padding: var(--dbu-space-8);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.placeholder-content {
  text-align: center;
  max-width: 600px;
}

.menu-navigation {
  margin-top: var(--dbu-space-6);
}

.navigation-tip {
  color: var(--dbu-gray-600);
  margin-bottom: var(--dbu-space-4);
  font-size: var(--dbu-text-base);
}

.menu-links {
  display: flex;
  gap: var(--dbu-space-4);
  justify-content: center;
  flex-wrap: wrap;
}

.menu-link {
  text-decoration: none;
}

.menu-link .el-button {
  display: flex;
  align-items: center;
  gap: var(--dbu-space-2);
}
</style>